<?php


namespace app\index\controller;
use app\common\model\TestModel;

class Delete
{
    private $testModel; // 测试表

    public function __construct()
    {
        $this->testModel = new TestModel();
    }

    public function index(){
        $batchSize = 1000;
        do {
            $result = $this->testModel->where('age', 195)->limit($batchSize)->delete();
            if($result === FALSE){
                return json(['status' => 'success', 'message' => '删除失败'])->code(500);
            }
        } while ($result);  // 删除操作会继续直到没有符合条件的数据

        return json(['status' => 'success', 'message' => '删除成功', 'data' => '删除条数据成功'])->code(200);
    }
}